package my.climbing;

import my.map.*;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.widget.*;
import android.view.*;

public class ClimbingProjectActivity extends Activity implements View.OnClickListener{

	Button b1, b2, b3;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        b1 = (Button)findViewById(R.id.button1);
        b1.setOnClickListener(this);
        
        b2 = (Button)findViewById(R.id.button2);
        b2.setOnClickListener(this);
        
        b3 = (Button)findViewById(R.id.button3);
        b3.setOnClickListener(this);
    }

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v.getId() == R.id.button1){
			Intent i = new Intent();
			i.setClass(this, ClimbingMap.class);
			startActivity(i);
		}
		
		if (v.getId() == R.id.button2){
			Intent i = new Intent();
			i.setClass(this, SelectMountainActivity.class);
			startActivity(i);
		}
		
		if (v.getId() == R.id.button3){
			Intent i = new Intent();
			i.setClass(this, SelectPathActivity.class);
			startActivity(i);
		}
	}
	
	public boolean onKeyDown(int keyCode, KeyEvent event){
		 switch(keyCode){
		 case KeyEvent.KEYCODE_BACK:
			 String alertTitle = getResources().getString(R.string.app_name);
			 String buttonMessage = getResources().getString(R.string.alert_msg_exit);
			 String buttonYes = getResources().getString(R.string.button_yes);
			 String buttonNo = getResources().getString(R.string.button_no);
	         
			 new AlertDialog.Builder(this)
			 .setTitle(alertTitle)
			 .setMessage(buttonMessage)
			 .setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {
	       
				 @Override
				 public void onClick(DialogInterface dialog, int which) {
					 // TODO Auto-generated method stub
					 moveTaskToBack(true);
					 finish();
				 }
			 })
			 .setNegativeButton(buttonNo, null)
			 .show();
		 }
		 return true;
	}

}